import request from '@/libs/request'
/**
 * 登录
 * @param data object 用户账号密码
 */

export function login (data) {
  return request.post('login', data, {
    login: false
  })
}

/**
 * 获取登录用户信息
 * @param token 用户账号密码
 */
export function getUserInfo () {
  return request.get('userinfo')
}

export function logout () {
  return request.get('logout')
}

export function merLoginPw (data) {
  return request.put('modifymerpw/' + data.uid, data, { login: true })
}

export function merPayPw (data) {
  return request.put('modifymerpaypw/' + data.uid, data)
}

export function createdpaid (data) {
  return request.post('createdpaid', data)
}

export function home (uid) {
  return request.get('home/' + uid)
}

export function getQR (uid) {
  return request.get('getqr/' + uid)
}

export function bindGoogle (data) {
  return request.put('bindgoogle/' + data.uid, data)
}

export function changesSecretKey (data) {
  return request.put('changessecretkey/' + data.uid, data)
}

export function changesLoginMode (data) {
  return request.put('changesloginmode/' + data.uid, data)
}
export function changesPayMode (data) {
  return request.put('changespaymode/' + data.uid, data)
}

/**
 * 充值提交
 * @param {Object} data
 */
export function merRecharge (data) {
  return request.post('offlinerecharge', data)
}

export function getRecharge (data) {
  return request.get('merrecharge', data)
}

export const getUnreadCount = () => {
  return axios.request({
    url: 'message/count',
    method: 'get'
  })
}

export const getMessage = () => {
  return axios.request({
    url: 'message/init',
    method: 'get'
  })
}

export const getContentByMsgId = msg_id => {
  return axios.request({
    url: 'message/content',
    method: 'get',
    params: {
      msg_id
    }
  })
}

export const hasRead = msg_id => {
  return axios.request({
    url: 'message/has_read',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const removeReaded = msg_id => {
  return axios.request({
    url: 'message/remove_readed',
    method: 'post',
    data: {
      msg_id
    }
  })
}

export const restoreTrash = msg_id => {
  return axios.request({
    url: 'message/restore',
    method: 'post',
    data: {
      msg_id
    }
  })
}
